package jschool.ui.Nomina;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;

import jschool.manejadores.ManejadorDeValorDeNomina;

public class ConfiguracionNomina extends JPanel {

	private static final long serialVersionUID = 1L;
	private JLabel lblIsr = null;
	private JLabel lblDatos = null;
	private JLabel lblArs = null;
	private JLabel lblSP = null;
	private JTextField txtISR = null;
	private JTextField txtARS = null;
	private JTextField txtSP = null;
	private JPanel panelConfiguraciones = null;
	private JButton btnConfigurar = null;
	private JLabel lblLeyenda = null;
	private ManejadorDeValorDeNomina manejador = ManejadorDeValorDeNomina
			.getInstancia();

	/**
	 * This is the default constructor
	 */
	public ConfiguracionNomina() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		lblLeyenda = new JLabel();
		lblLeyenda.setFont(new Font("Dialog", Font.PLAIN, 10));
		lblLeyenda.setBounds(new Rectangle(56, 164, 172, 58));
		lblLeyenda
				.setText("<html>Leyendas:<br>ISR : Impuesto sobre la Renta</br><br>ARS: Seguro Social de Salud</br><br>SP: Seguro de Pension</br></html>");
		lblSP = new JLabel();
		lblSP.setText("SP:");
		lblSP.setBounds(new Rectangle(24, 60, 31, 20));
		lblSP.setFont(new Font("Arial", Font.PLAIN, 12));
		lblArs = new JLabel();
		lblArs.setText("ARS:");
		lblArs.setBounds(new Rectangle(24, 39, 31, 20));
		lblArs.setFont(new Font("Arial", Font.PLAIN, 12));
		lblDatos = new JLabel();
		lblDatos.setHorizontalAlignment(SwingConstants.CENTER);
		lblDatos.setForeground(Color.WHITE);
		lblDatos.setBorder(BorderFactory.createLineBorder(Color.black, 1));
		lblDatos.setOpaque(true);
		lblDatos.setBackground(new Color(72, 129, 191));
		lblDatos.setBounds(new Rectangle(9, 6, 287, 20));
		lblDatos.setFont(new Font("Arial", Font.PLAIN, 12));
		lblDatos.setText("Datos de Nomina");
		lblIsr = new JLabel();
		lblIsr.setFont(new Font("Arial", Font.PLAIN, 12));
		lblIsr.setBounds(new Rectangle(24, 18, 31, 20));
		lblIsr.setText("ISR:");
		this.setSize(308, 236);
		this.setLayout(null);
		this.add(lblDatos, null);
		this.add(getPanelConfiguraciones(), null);
		this.add(getBtnConfigurar(), null);
		this.add(lblLeyenda, null);
	}

	/**
	 * This method initializes txtISR
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtISR() {
		if (txtISR == null) {
			txtISR = new JTextField();
			txtISR.setBorder(BorderFactory.createLineBorder(Color.black, 1));
			txtISR.setBounds(new Rectangle(57, 18, 107, 20));
			txtISR.setText(manejador.getValores()[1].toString());
		}
		return txtISR;
	}

	/**
	 * This method initializes txtARS
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtARS() {
		if (txtARS == null) {
			txtARS = new JTextField();
			txtARS.setBorder(BorderFactory.createLineBorder(Color.black, 1));
			txtARS.setBounds(new Rectangle(57, 39, 107, 20));
			txtARS.setText(manejador.getValores()[2].toString());
		}
		return txtARS;
	}

	/**
	 * This method initializes txtSP
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtSP() {
		if (txtSP == null) {
			txtSP = new JTextField();
			txtSP.setBorder(BorderFactory.createLineBorder(Color.black, 1));
			txtSP.setBounds(new Rectangle(57, 60, 107, 20));
			txtSP.setText(manejador.getValores()[3].toString());
		}
		return txtSP;
	}

	/**
	 * This method initializes panelConfiguraciones
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getPanelConfiguraciones() {
		if (panelConfiguraciones == null) {
			panelConfiguraciones = new JPanel();
			panelConfiguraciones.setLayout(null);
			panelConfiguraciones.setBounds(new Rectangle(56, 34, 185, 91));
			panelConfiguraciones.add(lblSP, null);
			panelConfiguraciones.add(getTxtSP(), null);
			panelConfiguraciones.add(getTxtARS(), null);
			panelConfiguraciones.add(lblArs, null);
			panelConfiguraciones.add(lblIsr, null);
			panelConfiguraciones.add(getTxtISR(), null);
			panelConfiguraciones.setBorder(BorderFactory.createCompoundBorder(
					BorderFactory.createEmptyBorder(0, 0, 0, 0), BorderFactory
							.createTitledBorder(null, "Configuracion",
									TitledBorder.LEFT,
									TitledBorder.DEFAULT_POSITION, new Font(
											"Courier New", Font.PLAIN, 12),
									new Color(51, 51, 51))));
		}
		return panelConfiguraciones;
	}

	/**
	 * This method initializes btnConfigurar
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getBtnConfigurar() {
		if (btnConfigurar == null) {
			btnConfigurar = new JButton();
			btnConfigurar.setBounds(new Rectangle(56, 132, 185, 25));
			btnConfigurar.setText("Cambiar Configuracion");
			btnConfigurar
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							manejador.modificarValorNomina(Double
									.parseDouble(txtISR.getText()), Double
									.parseDouble(txtARS.getText()), Double
									.parseDouble(txtSP.getText()));
						}
					});
		}
		return btnConfigurar;
	}
} // @jve:decl-index=0:visual-constraint="11,8"
